Skip to content

Comments

Fix failed assertion in build_response for 1xx races#12866

Open
bneradt wants to merge 1 commit intoapache:masterfrom
bneradt:fix-1xx-build-response-assert
Open

Fix failed assertion in build_response for 1xx races#12866
bneradt wants to merge 1 commit intoapache:masterfrom
bneradt:fix-1xx-build-response-assert

Conversation

@bneradt
Copy link
Contributor

@bneradt bneradt commented Feb 6, 2026

This failed assertion was seen sometimes when running the cache-tests.

When a 1xx informational response (such as 103 Early Hints) is forwarded to the client, its headers are copied into client_response and sent via an asynchronous tunnel. The tunnel completion handler (tunnel_handler_100_continue) destroys client_response when the tunnel finishes. However, if the final server response arrives and build_response is called before the tunnel completes, client_response is still valid, triggering the assertion !new_hdr->valid() in copy_header_fields.

This patch addresses this by defensively destroying outgoing_response in build_response if it is already valid before calling copy_header_fields. The header data from the 1xx has already been serialized into the tunnel buffer and is no longer needed, so this should be safe.

This failed assertion was seen sometimes when running the cache-tests.

When a 1xx informational response (such as 103 Early Hints) is forwarded
to the client, its headers are copied into client_response and sent via
an asynchronous tunnel. The tunnel completion handler
(tunnel_handler_100_continue) destroys client_response when the tunnel
finishes. However, if the final server response arrives and
build_response is called before the tunnel completes, client_response is
still valid, triggering the assertion `!new_hdr->valid()` in
copy_header_fields.

This patch addresses this by defensively destroying outgoing_response in
build_response if it is already valid before calling copy_header_fields.
The header data from the 1xx has already been serialized into the tunnel
buffer and is no longer needed, so this should be safe.
@bneradt bneradt added this to the 10.2.0 milestone Feb 6, 2026
@bneradt bneradt self-assigned this Feb 6, 2026
@cmcfarlen cmcfarlen modified the milestones: 10.2.0, 11.0.0 Feb 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a race condition that causes an assertion failure in build_response when handling HTTP 1xx informational responses (such as 100 Continue or 103 Early Hints). The issue occurs when the final server response arrives before the asynchronous tunnel that forwards the 1xx response to the client completes.

Changes:

  • Added a defensive check in build_response to destroy outgoing_response if it's already valid before calling copy_header_fields
  • This prevents the assertion failure in copy_header_fields which expects the new header to be invalid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants